<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
    <meta name="format-detection"content="telephone=no, email=no" />
    <meta name="apple-mobile-web-app-capable" content="yes" /><!-- 删除苹果默认的工具栏和菜单栏 -->
    <meta name="apple-mobile-web-app-status-bar-style" content="black" /><!-- 设置苹果工具栏颜色 -->
    <meta name="renderer" content="ie-comp">
    <meta name="renderer" content="ie-stand">
    <meta name="renderer" content="webkit"> 
    <meta name="keywords" content="耀盛中国,耀盛智投,理财产品,智选财富,耀盛智投官网"/>
    <meta name="description" content="耀盛智投为耀盛中国旗下理财产品智选平台。专注于为大众富裕阶层、精英个人、中产阶级家庭、合规机构等提供定制化资产配置咨询推荐服务，帮助客户实现财富的增值。" />
    <title>风险评测</title>
    <script src="../../lib/js/ftSize.js"></script>
    <link rel="stylesheet" href="../../lib/css/_base.css">
    <link rel="stylesheet" type="text/css" href="../../lib/css/exposureRating.css">
    <link rel="stylesheet" href="../../lib/css/publicBubb.css">
</head>
<body>
    <h1 class="rem90R"><img src="../../lib/images/left.png" class="leftImg" onClick="prevAttectation()">风险评测</h1>

    <div class="appraisal_list product-main" id="exposureMain">
    </div>
           <!--  <div class="exposureMain-pic">
                <div class="question_number"><span>1</span> / 8</div>
                <p class="exposureWarn"><span>您的年龄在以下哪个范围内？</span><i>*</i><em class="error" >请选择</em></p>
                <ul class="issue">
                    <li>
                        <label>
                            <input type="radio" class="checkbox" name="a">
                            <s></s>
                            <span>有购、</span>
                        </label>
                    </li>
                    <li>
                        <label>
                            <input type="radio" class="checkbox" name="a">
                            <s></s>
                            <span>希望赚取最高回报潜力，能接受3年以上的负面波动，包括损失本金</span>
                        </label>
                    </li>
                    <li>
                    <label>
                            <input type="radio" class="checkbox" name="a">
                            <s></s>
                            <span>寻求</span>
                        </label>
                    </li>
                    <li>
                    <label>
                            <input type="radio" class="checkbox" name="a">
                            <s></s>
                            <span>希望赚取最高回报潜力，能接受3年以上的负面波动，包括损失本金</span>
                        </label>

                    </li>
                    <li>
                        <label>
                            <input type="radio" class="checkbox" name="a">
                            <s></s>
                            <span>本金不保证，收益率在20%以内，同时本金也有可能亏损10%以内</span>
                        </label>
                    </li>
                </ul>    
            </div>
        </div> -->
<!--  <div class="onTopic" onClick="prevPic()">上一题</div> -->
<div id="topPapers" onClick="exposureMaskShow()">提交</div>
<!-- 弹窗 -->
<div class="maskWrap" id="exposureMask">
    <div class="maskLayer">
        <div class="maskTitle" style=" margin:.8rem auto .44rem;">风险承受能力评估</div>
        <div class="maskContented" id="exposurType"></div>
        <div class="maskbtnGroup">
            <a href="../../home/index.html"> <span class="winBg">立即投资</span></a>
            <a href="exposureRating.html"><span> 重新评测</span></a>
        </div>  
    </div>
</div>
<script src="../../lib/js/jquery.min.js"></script>    
<script src="../../lib/js/public-header.js"></script> 
<script>
let listed='',radioLen=0,elementMount='';
//let userId = JSON.parse( window.sessionStorage.getItem("wpuserInfo")).userId;//是否有登录信息

$('#exposureMask').hide();
//查询测评题
    function RiskpicJson() {
        let wpuserToken = window.sessionStorage.getItem("wpuserToken");//tiken
        var json = {
            "faceCode":"risk/getRisk",
            "token":wpuserToken,    
            "clientInfo":"W,100,IE8",  
            "requestTime": formatDateTime(startTime),
            "body":{
                
            }
        }
        return json;
    }
//  提交测评答案
    function riskresultJson(list) {
        let wpuserToken = window.sessionStorage.getItem("wpuserToken");//tiken
        var json = {
            "faceCode":"risk/evaluateRisk",
            "token":wpuserToken,    
            "clientInfo":"W,100,IE8",  
            "requestTime": formatDateTime(startTime),
            "body":{
                "idStr":list
            }
        }
        return json;
    }
    //查询测评结果
    function seachriskJson() {
        let wpuserToken = window.sessionStorage.getItem("wpuserToken");//tiken
        var json = {
            "faceCode":"risk/getRiskResult",
            "token":wpuserToken,    
            "clientInfo":"W,100,IE8",  
            "requestTime": formatDateTime(startTime),
            "body":{
                "userId":JSON.parse( window.sessionStorage.getItem("wpuserInfo")).userId
            }
        }
        return json;
    }

    $.ajax({  
        type: "POST",
        url: httpServer+"risk/getRisk",
        headers:{
            'Access-Control-Allow-Origin':'*'
        }, 
        contentType: "application/json; charset=utf-8",
        data: JSON.stringify(RiskpicJson()),
        dataType: "json",
        success: function (ispicAuth) {
            if(ispicAuth.resCode!='0' ){
                twoError(ispicAuth)
            }else{
                var myQuestions= ispicAuth.body;
                const output = [];
                radioLen=ispicAuth.body.length;
                myQuestions.forEach((currentQuestion, questionNumber) => {
                const answers = [];
                
                    for (letter in currentQuestion.optionList) {
                      
                        answers.push(
                        `<li index="${questionNumber}" name="${currentQuestion.seqNum}" ><label for="${currentQuestion.seqNum}_`+((letter)*1+1)+`_${currentQuestion.optionList[letter].score}">
                                <input type="radio" class="checkbox" id="${currentQuestion.seqNum}_`+((letter)*1+1)+`_${currentQuestion.optionList[letter].score}" name="cs${currentQuestion.seqNum}" value="${currentQuestion.optionList[letter].options}" check-input="${currentQuestion.seqNum}_`+((letter)*1+1)+`_${currentQuestion.optionList[letter].score}" onClick="changeBg(`+currentQuestion.optionList[letter].id+`,`+currentQuestion.optionList[letter].userRiskId+`,`+currentQuestion.optionList[letter].score+`,`+questionNumber+`)"/>
                                <s></s>
                                <span> ${currentQuestion.optionList[letter].options}.
                            ${currentQuestion.optionList[letter].optionDesc}</span>
                            
                        </label>`
                        );
                    }
                       
                        output.push(
                            `<div class="exposureMain-pic" id="question${currentQuestion.seqNum}" articleTitle="false">
                                    <a class="question_number" name="cs${currentQuestion.seqNum}"><span>${currentQuestion.seqNum}</span>/ ${radioLen}</a>  <p class="exposureWarn"><span>${currentQuestion.title}?</span><em class="error">请选择</em></p> </div>
                            <ul class="issue"> ${answers.join("")} </ul>
                            </div>`
                        );
                    //});
                });
            $('#exposureMain').html(output.join(""));
            }
                
      },
      error: function(error){  
      
      }    
  }); 

    function changeBg(tremId,selId,scopeId,ids){

       $('#exposureMain .exposureMain-pic').eq(ids).attr('articleTitle',true);
     
        listed += tremId+','+selId+','+scopeId+'|';
       
    }
    //提交
    function exposureMaskShow(){
        let checkList= $("input[type='radio']:checked");
        var age=$("input[type='radio']:checked").attr('name');
       if(!age){
           
          
       }else{
        //window.location.href = "#"+age;
       
       }
        let checkListlen= checkList.length;
        if(radioLen===checkListlen){
            $.ajax({  
                type: "POST",
                url: httpServer+"risk/evaluateRisk",
                headers:{
                    'Access-Control-Allow-Origin':'*'
                }, 
                async:false,
                contentType: "application/json; charset=utf-8",
                data: JSON.stringify(riskresultJson(listed)),
                dataType: "json",
                success: function (exposurShow) {  
                   if(exposurShow.resCode!='0'){
                    twoError(exposurShow)
                   }else{
                    $.ajax({  
                        type: "POST",
                        url: httpServer+"risk/getRiskResult",
                        headers:{
                            'Access-Control-Allow-Origin':'*'
                        }, 
                        async:false,
                        contentType: "application/json; charset=utf-8",
                        data: JSON.stringify(seachriskJson()),
                        dataType: "json",
                        success: function (exposurultShow) {  
                        if(exposurultShow.resCode!='0'){
                            twoError(exposurShow)
                        }else{
                            let riskType=exposurultShow.body.riskType;
                             window.sessionStorage.setItem('wpriskFlag','1');//1测评0未测评
                             
                             switch(riskType){
                                 case '00':
                                 riskType='保守型';
                                 break;
                                 case '01':
                                 riskType='稳健型';
                                 break;
                                 case '02':
                                 riskType='平衡型';
                                 break;
                                 case '03':
                                 riskType='成长型';
                                 break;
                                 default:
                                 riskType='进取型';
                                
                             }
                             $('#exposureMask').show();
                             $('#exposurType').text(riskType)
                        }
                        },
                        error: function(error){  
                            console.log(error,3);  
                        }    
                    }); 
                   }
                },
                error: function(error){  
                    console.log(error,3);  
                }    
            }); 
        }else{
            $.each($('#exposureMain .exposureMain-pic'),function(itemId,item){
               if($('#exposureMain .exposureMain-pic').eq(itemId).attr('articleTitle')!='true' ){
                $('.exposureWarn em').eq(itemId).css('display','inline-block');
               }else{
                $('.exposureWarn em').eq(itemId).css('display','none');
               }

            })
        }
    }
</script>

</body>
</html>